package com.fs.iot.web;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fs.iot.bean.dto.AlarmDTO;
import com.fs.iot.bean.query.AlarmQuery;
import com.fs.iot.service.AlarmEntityService;
import com.fs.iot.service.AlarmService;
import com.fs.iot.vo.AlarmVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 报警控制器 
 * @author Coder Generator 2025-03-24 17:08:23 
 **/
@RestController
@RequestMapping("/manager/alarm")
@Slf4j
@Tag(name = "报警控制器")
public class AlarmController {
    @Autowired
    private AlarmEntityService service;

    @Autowired
    private AlarmService alarmService;

    @DeleteMapping("delete/{id}")
    @Operation(summary = "删除")
    public void delete(@PathVariable("id") String id) {
        service.delete(id);
    }

    @GetMapping("detail/{id}")
    @Operation(summary = "根据id查找记录")
    public AlarmVO findById(@PathVariable("id") String id) {
        return alarmService.findById(id).orElse(null);
    }

    @PostMapping("page-query")
    @Operation(summary = "查询-分页")
    public IPage<AlarmVO> pageQuery(@RequestBody AlarmQuery query) {
        return alarmService.pageQuery(query);
    }

    @PostMapping("query")
    @Operation(summary = "查询-不分页")
    public List<AlarmDTO> query(@RequestBody AlarmQuery query) {
        return service.query(query);
    }
}